
******************************************************
* 				Replication do-file                  *
*         Review of Economics and Statistics         *
*                                                    *
*               Choosing Your Pond                   *
*       Location Choices and Relative Income         *
*                                                    *
*		Nicolas Bottan & Ricardo Perez-Truglia       *
*                                                    *
*                   September 2020                   *
*                                                    *
******************************************************
/*

                    Notes
					
This do-file replicates Appendix Tables from the paper. 

The analysis makes use of survey data on medical students 
participating in the NRMP, and as such is highly sensitive
and cannot be posted.

Please contact the authors if you are interested in having
them conduct any additional analysis.

*** Install Stata commands
cap: ssc install renames
cap: ssc install ivreg2
cap: ssc install ranktest 
cap: ssc install esttab
cap: ssc install outreg2
cap: ssc install parmest
cap: ssc install qqvalue
cap: ssc install quantiles
*/



*** Set WD

cd ""		// Set path for main folder here



*** Figure 1: Variation in Earnings Rank and Cost of Living
* a) In levels
use "Main Experiment/mainexperiment_confidential.dta", clear
preserve

keep id colhat* rpphat* incacs* inccps* metro* z_incacs* z_inccps*

reshape long colhat rpphat incacs inccps metro z_incacs z_inccps, i(id) j(j)

gen cou=1
collapse (first) z_* colhat rpphat (sum) cou, by(metro)

reg rpp z_incacs [w=cou], r
local b=string(_b[z_incacs], "%9.3f")
local s=string(_se[z_incacs], "%9.3f")
local r2=string(e(r2), "%9.3f")

twoway (scatter rpphat z_incacs [w=cou], msize(vsmall) mcolor(black)) (lfit rpphat z_incacs, lcolor(black)), scheme(s1mono) ytitle("Cost of Living (RPP)") xtitle("Earnings Rank (ACS)") xline(57.9, lpattern(dash) lcolor(gs7)) yline(106, lpattern(dash) lcolor(gs7)) legend(label(1 "Weighted data") label(2 "OLS") c(1) r(3) position(2) ring(0) region(lcolor(none) fcolor(none))) note("          {&beta} = `b' (`s')" "          R{superscript:2} = `r2'           " " " " ", position(7) ring(0) size(medsmall))
graph export "results/Figure1a.eps", replace	// Note: labels and coloring added manually.
graph close

restore

* b) In relative terms
preserve

gen relrpp = rpphat1 - rpphat2
gen relcol = colhat1 - colhat2
gen relacs = incacs1 - incacs2
gen relcps = inccps1 - inccps2

tempfile aux
save "`aux'", replace

use "`aux'", clear

quantiles relacs, n(19) k(relacs) gen(group)
centile relacs, c(5(5)95)
forvalues k=1/19 {
	replace group=r(c_`k') if group==`k'
	}

tempfile aux0
save "`aux0'", replace

collapse (mean) relrpp , by(group)

gen bs=1
rename group relacs

append using "`aux0'"

reg relrpp relacs, r
local b=string(_b[relacs], "%9.3f")
local s=string(_se[relacs], "%9.3f")
local r2=string(e(r2), "%9.3f")
local n=string(e(N), "%9.0fc")
		
sort relacs
twoway (scatter relrpp relacs if bs==., msize(tiny) m(O) mcolor(gs12)) (scatter relrpp relacs if bs==1, msize(small) m(O) mcolor(gs1)) (lfit relrpp relacs if bs==., lcolor(gs1)), scheme(s1mono)  ytitle("Pairwise Difference of Cost of Living (RPP)") xtitle("Pairwise Difference of Earnings Rank (ACS)") legend(label(1 "Raw data") label(2 "Binned Scatter") label(3 "OLS") label(4 "45{c 176} line") c(1) r(3) position(2) ring(0) region(lcolor(none) fcolor(none))) note("      {&beta} = `b' (`s')" "      R{superscript:2} = `r2'           " "      N=`n'     " " ", position(7) ring(0) size(medsmall))
graph export "results/Figure1b.eps", replace
graph close
restore
	

	
	
	
	
	
	

*** Figure 1c-d: Accuracy of prior beliefs
use "Main Experiment/mainexperiment_confidential.dta", clear

foreach var in pre_px pre_inc { 
preserve

forvalues i=1/2 {

gen px_shown`i' = rpphat`i'
gen inc_shown`i' = incacs`i'

}

keep id pre_px* pre_inc* inc_shown* px_shown* pre_relpx pre_relinc

reshape long pre_px pre_inc inc_shown px_shown , i(id) j(j)

gen px_error=(px_shown-pre_px)/px_shown*100
gen inc_error=(inc_shown-pre_inc)/inc_shown*100

if "`var'"=="pre_px" {
	local depvar "px_shown"
}
else {
	local depvar "inc_shown"
}

quantiles `depvar', n(19) k(`var') gen(group)
centile `depvar', c(5(5)95)
forvalues k=1/19 {
	replace group=r(c_`k') if group==`k'
	}
	
tempfile aux0
save "`aux0'", replace

collapse (mean) `var', by(group)

gen bs=1
rename group `depvar'

append using "`aux0'"

qui: cou
local N=r(N)+2
set obs `N'
qui: sum `depvar'
replace bs=2 if `depvar'==.

if "`var'"=="pre_px" {
	replace `depvar'=50 if `depvar'==. & _n==(`N'-1)
	replace `depvar'=150 if `depvar'==. & _n==(`N')
}
else {
	replace `depvar'=0 if `depvar'==. & _n==(`N'-1)
	replace `depvar'=100 if `depvar'==. & _n==(`N')
}

reg `var' `depvar'  if bs==.
local a0=_b[_cons]
local a1=_b[`depvar']
predict p`depvar' if bs==2
local b=string(_b[`depvar'], "%9.3f")
local s=string(_se[`depvar'], "%9.3f")
local r2=string(e(r2), "%9.3f")
local n=string(e(N), "%9.0fc")

if "`var'"=="pre_px" {
	replace `depvar'=((50-`a0')/`a1') if _n==(`N'-1)
	replace `depvar'=((150-`a0')/`a1') if _n==(`N')
	replace p`depvar'=50 if _n==(`N'-1)
	replace p`depvar'=150 if _n==(`N')	

	twoway (scatter `var' `depvar' if bs==., msize(tiny) mcolor(gs12) m(O)) (scatter `var' `depvar' if bs==1, msize(small) mcolor(gs1) m(O)) (line p`depvar' `depvar' if bs==2, lcolor(gs1)) (line p`depvar' p`depvar' if bs==2, lcolor(gs7) lpattern(dash)), scheme(s1mono)  ytitle("Respondent's Prior Belief") xtitle("Estimate from the Regional Price Parity") xtick(50(20)150) xlabel(50(20)150) ytick(50(20)150) ylabel(50(20)150) legend(label(1 "Raw data") label(2 "Binned Scatter") label(3 "OLS") label(4 "45{c 176} line") c(1) r(4) position(10) ring(0) region(lcolor(none) fcolor(none))) note("          {&beta} = `b' (`s')" "          R{superscript:2} = `r2'           " "          N = `n'            " " ", position(4) ring(0) size(medsmall))
		graph export "results/`depvar'_`var'_binscatter.eps", replace
		graph close
	}
else  {
	twoway (scatter `var' `depvar' if bs==., msize(tiny) mcolor(gs12) m(O)) (scatter `var' `depvar' if bs==1, msize(small) mcolor(gs1) m(O)) (line p`depvar' `depvar'  if bs==2, lcolor(gs1))  (line `depvar' `depvar' if bs==2, lcolor(gs7) lpattern(dash)), scheme(s1mono)  ytitle("Respondent's Prior Belief") xtitle("Estimate from the American Community Survey") xtick(0(20)100) xlabel(0(20)100) ytick(0(20)100) ylabel(0(20)100) legend(label(1 "Raw data") label(2 "Binned Scatter") label(3 "OLS") label(4 "45{c 176} line") c(1) r(4) position(10) ring(0) region(lcolor(none) fcolor(none))) note("          {&beta} = `b' (`s')" "          R{superscript:2} = `r2'           " "          N = `n'            " " ", position(4) ring(0) size(medsmall))
		graph export "results/`depvar'_`var'_binscatter.eps", replace
		graph close
	}

restore
}

!mv results/inc_shown_pre_inc_binscatter.eps  results/Figure1c.eps
!mv results/px_shown_pre_px_binscatter.eps  results/Figure1d.eps










*** Figure 2: Learning
use "Main Experiment/mainexperiment_confidential.dta", clear
* Learning
foreach var in px_pregap inc_pregap { 
preserve

forvalues i=1/2 {
gen px_shown`i' = colhat`i' if sourcecol=="colhat"
replace px_shown`i' = rpphat`i' if sourcecol=="rpphat"
gen px_diff`i'=post_px`i'-pre_px`i'
gen lr_px_diff`i'=lr_px`i'-pre_px`i'
gen px_pregap`i'=px_shown`i'-pre_px`i'
gen px_shown_fake`i' = rpphat`i' if sourcecol=="colhat"
replace px_shown_fake`i' = colhat`i' if sourcecol=="rpphat"
gen px_pregap_fake`i'=px_shown_fake`i'-pre_px`i'

gen inc_shown`i' = incacs`i' if sourceinc=="acs"
replace inc_shown`i' = inccps`i' if sourceinc=="cps"
gen inc_diff`i'=post_inc`i'-pre_inc`i'
gen lr_inc_diff`i'=lr_inc`i'-pre_inc`i'
gen inc_pregap`i'=inc_shown`i'-pre_inc`i'
gen inc_shown_fake`i' = incacs`i' if sourcecol=="colhat"
replace inc_shown_fake`i' = inccps`i' if sourcecol=="rpphat"
gen inc_pregap_fake`i'=inc_shown_fake`i'-pre_inc`i'
}

keep id px_diff* px_pregap* px_pregap_fake* inc_diff* inc_pregap* inc_pregap_fake* lr_px_diff* lr_inc_diff* sourcecol sourceinc

reshape long px_diff px_pregap px_pregap_fake inc_diff inc_pregap inc_pregap_fake lr_px_diff lr_inc_diff, i(id) j(j)

reg px_diff px_pregap
predict px_resid, resid
reg inc_diff inc_pregap
predict inc_resid, resid

reg lr_px_diff px_pregap
predict lr_px_resid, resid
reg lr_inc_diff inc_pregap
predict lr_inc_resid, resid

quantiles `var', n(19) k(`var') gen(group)
centile `var', c(5(5)95)
forvalues k=1/19 {
	replace group=r(c_`k') if group==`k'
	}

if "`var'"=="px_pregap" {
	local depvar "px_diff"
}
else {
	local depvar "inc_diff"
}

tempfile aux0
save "`aux0'", replace

collapse (mean) `depvar' lr_`depvar', by(group)

gen bs=1
rename group `var'

append using "`aux0'"

qui: cou
local N=r(N)+2
set obs `N'
qui: sum `var'
replace bs=2 if `var'==.
replace `var'=r(min) if `var'==. & _n==(`N'-1)
replace `var'=r(max) if `var'==. & _n==(`N')

reg `depvar' `var' if bs==.
predict p`depvar' if bs==2
local b=string(_b[`var'], "%9.3f")
local s=string(_se[`var'], "%9.3f")
local r2=string(e(r2), "%9.3f")
local n=string(e(N),"%9.0fc")
reg lr_`depvar' `var' if bs==.
predict plr_`depvar' if bs==2
local lr_b=string(_b[`var'], "%9.3f")
local lr_s=string(_se[`var'], "%9.3f")
local lr_r2=string(e(r2), "%9.3f")
local lr_n=string(e(N),"%9.0fc")

if "`var'"=="px_pregap" {
	twoway (scatter `depvar' `var' if bs==., msize(tiny) mcolor(gs12) m(O)) (scatter `depvar' `var' if bs==1, msize(small) mcolor(gs1) m(O)) (line p`depvar' `var' if bs==2, lcolor(gs1)) , scheme(s1mono) xline(0, lpattern(dot) lcolor(gs5)) yline(0, lpattern(dot) lcolor(gs5)) xtick(-60(20)80) xlabel(-60(20)80) ytick(-80(20)80) ylabel(-80(20)80) ytitle("(Posterior Belief - Prior Belief)") xtitle("(Feedback Provided - Prior Belief)") legend(label(1 "Raw data") label(2 "Binned Scatter") label(3 "OLS") c(1) r(3) position(11) ring(0) region(lcolor(none) fcolor(none))) note("          {&alpha} = `b' (`s')" "          N=`n'              " " ", position(5) ring(0) size(medsmall))
		graph export "results/`depvar'_`var'_binscatter.eps", replace
		graph close

	local depvar "lr_`depvar'"
	twoway (scatter `depvar' `var' if bs==., msize(tiny) mcolor(gs12) m(O)) (scatter `depvar' `var' if bs==1, msize(small) mcolor(gs1) m(O)) (line p`depvar' `var' if bs==2, lcolor(gs1)) , scheme(s1mono) xline(0, lpattern(dot) lcolor(gs5)) yline(0, lpattern(dot) lcolor(gs5)) xtick(-60(20)80) xlabel(-60(20)80) ytick(-80(20)80) ylabel(-80(20)80) ytitle("(Posterior Belief - Prior Belief)") xtitle("(Feedback Provided - Prior Belief)") legend(label(1 "Raw data") label(2 "Binned Scatter") label(3 "OLS") c(1) r(3) position(11) ring(0) region(lcolor(none) fcolor(none))) note("          {&alpha} = `lr_b' (`lr_s')" "          N=`lr_n'              " " ", position(5) ring(0) size(medsmall))
		graph export "results/`depvar'_`var'_binscatter.eps", replace
		graph close
	}
else  {
	twoway (scatter `depvar' `var' if bs==., msize(tiny) mcolor(gs12) m(O)) (scatter `depvar' `var' if bs==1, msize(small) mcolor(gs1) m(O)) (line p`depvar' `var' if bs==2, lcolor(gs1)) , scheme(s1mono) xline(0, lpattern(dot) lcolor(gs5)) yline(0, lpattern(dot) lcolor(gs5)) xtick(-60(20)80) xlabel(-60(20)80) ytick(-80(20)80) ylabel(-80(20)80) ytitle("(Posterior Belief - Prior Belief)") xtitle("(Feedback Provided - Prior Belief)") legend(label(1 "Raw data") label(2 "Binned Scatter") label(3 "OLS") c(1) r(3) position(11) ring(0) region(lcolor(none) fcolor(none))) note("          {&alpha} = `b' (`s')" "          N=`n'              " " ", position(5) ring(0) size(medsmall))
		graph export "results/`depvar'_`var'_binscatter.eps", replace
		graph close

	local depvar "lr_`depvar'"
	twoway (scatter `depvar' `var' if bs==., msize(tiny) mcolor(gs12) m(O)) (scatter `depvar' `var' if bs==1, msize(small) mcolor(gs1) m(O)) (line p`depvar' `var' if bs==2, lcolor(gs1)) , scheme(s1mono) xline(0, lpattern(dot) lcolor(gs5)) yline(0, lpattern(dot) lcolor(gs5)) xtick(-60(20)80) xlabel(-60(20)80) ytick(-80(20)80) ylabel(-80(20)80) ytitle("(Posterior Belief - Prior Belief)") xtitle("(Feedback Provided - Prior Belief)") legend(label(1 "Raw data") label(2 "Binned Scatter") label(3 "OLS") c(1) r(3) position(11) ring(0) region(lcolor(none) fcolor(none))) note("          {&alpha} = `lr_b' (`lr_s')" "          N=`lr_n'              " " ", position(5) ring(0) size(medsmall))
		graph export "results/`depvar'_`var'_binscatter.eps", replace
		graph close
	}

restore
}

!mv results/inc_diff_inc_pregap_binscatter.eps  results/Figure2a.eps
!mv results/lr_inc_diff_inc_pregap_binscatter.eps  results/Figure2c.eps

!mv results/px_diff_px_pregap_binscatter.eps  results/Figure2d.eps
!mv results/lr_px_diff_px_pregap_binscatter.eps  results/Figure2f.eps


* 2.b 2.e: Placebos, Cross-Learning (SR & LR)
preserve

forvalues i=1/2 {
gen px_shown`i' = colhat`i' if sourcecol=="colhat"
replace px_shown`i' = rpphat`i' if sourcecol=="rpphat"
gen px_diff`i'=post_px`i'-pre_px`i'
gen lr_px_diff`i'=lr_px`i'-pre_px`i'
gen px_pregap`i'=px_shown`i'-pre_px`i'
gen px_shown_fake`i' = rpphat`i' if sourcecol=="colhat"
replace px_shown_fake`i' = colhat`i' if sourcecol=="rpphat"
gen px_pregap_fake`i'=px_shown_fake`i'-pre_px`i'

gen inc_shown`i' = incacs`i' if sourceinc=="acs"
replace inc_shown`i' = inccps`i' if sourceinc=="cps"
gen inc_diff`i'=post_inc`i'-pre_inc`i'
gen lr_inc_diff`i'=lr_inc`i'-pre_inc`i'
gen inc_pregap`i'=inc_shown`i'-pre_inc`i'
gen inc_shown_fake`i' = incacs`i' if sourcecol=="colhat"
replace inc_shown_fake`i' = inccps`i' if sourcecol=="rpphat"
gen inc_pregap_fake`i'=inc_shown_fake`i'-pre_inc`i'

}

keep id px_diff* px_pregap* px_pregap_fake* inc_diff* inc_pregap* inc_pregap_fake* lr_px_diff* lr_inc_diff* sourcecol sourceinc

reshape long px_diff px_pregap px_pregap_fake inc_diff inc_pregap inc_pregap_fake lr_px_diff lr_inc_diff, i(id) j(j)

*** Placebos
* ER 
reg inc_diff inc_pregap
predict yhat, resid
reg inc_pregap_fake inc_pregap
predict xhat, resid

reg yhat xhat, r
local b=string(_b[xhat], "%9.3f")
local s=string(_se[xhat], "%9.3f")
local r2=string(e(r2), "%9.3f")
local n=string(e(N),"%9.0fc")

quantiles xhat, n(19) k(xhat) gen(group)
centile xhat, c(5(5)95)
forvalues k=1/19 {
	replace group=r(c_`k') if group==`k'
	}

egen bs_yhat=mean(yhat), by(group)
bys group: replace bs_yhat=. if _n>1

twoway (scatter yhat xhat, msize(tiny) mcolor(gs12) m(O)) (scatter bs_yhat group, msize(small) mcolor(gs1) m(O)) (lfit yhat xhat, lcolor(gs1)), scheme(s1mono) xline(0, lpattern(dot) lcolor(gs5)) yline(0, lpattern(dot) lcolor(gs5))  ytitle("Adjusted (Posterior Belief - Prior Belief)") xtitle("Adjusted (Feedback Provided - Prior Belief)") legend(label(1 "Raw data") label(2 "Binned Scatter") label(3 "OLS") c(1) r(3) position(11) ring(0) region(lcolor(none) fcolor(none))) note("          {&alpha} = `b' (`s')" "          N=`n'              " " ", position(5) ring(0) size(medsmall))
	graph export "results/Figure2b.eps", replace
	graph close

drop yhat xhat group bs_yhat

* COL 
reg px_diff px_pregap
predict yhat, resid
reg px_pregap_fake px_pregap
predict xhat, resid

reg yhat xhat, r
local b=string(_b[xhat], "%9.3f")
local s=string(_se[xhat], "%9.3f")
local r2=string(e(r2), "%9.3f")
local n=string(e(N),"%9.0fc")

quantiles xhat, n(19) k(xhat) gen(group)
centile xhat, c(5(5)95)
forvalues k=1/19 {
	replace group=r(c_`k') if group==`k'
	}

egen bs_yhat=mean(yhat), by(group)
bys group: replace bs_yhat=. if _n>1

twoway (scatter yhat xhat, msize(tiny) mcolor(gs12) m(O)) (scatter bs_yhat group, msize(small) mcolor(gs1) m(O)) (lfit yhat xhat, lcolor(gs1)), scheme(s1mono) xline(0, lpattern(dot) lcolor(gs5)) yline(0, lpattern(dot) lcolor(gs5))  ytitle("Adjusted (Posterior Belief - Prior Belief)") xtitle("Adjusted (Feedback Provided - Prior Belief)") legend(label(1 "Raw data") label(2 "Binned Scatter") label(3 "OLS") c(1) r(3) position(11) ring(0) region(lcolor(none) fcolor(none))) note("          {&alpha} = `b' (`s')" "          N=`n'               " " ", position(5) ring(0) size(medsmall))
	graph export "results/Figure2e.eps", replace
	graph close

drop yhat xhat group bs_yhat










*** Appendix Figure A1: Comparison of Feedback Across the Two Data Sources
use "Main Experiment/mainexperiment_confidential.dta", clear

gen relrpp = rpphat1 - rpphat2
gen relcol = colhat1 - colhat2
gen relacs = incacs1 - incacs2
gen relcps = inccps1 - inccps2


quantiles relcol, n(19) k(relcol) gen(group)
centile relcol, c(5(5)95)
forvalues k=1/19 {
	replace group=r(c_`k') if group==`k'
	}

tempfile aux0
save "`aux0'", replace

collapse (mean) relrpp , by(group)

gen bs=1
rename group relcol

append using "`aux0'"

qui: cou
local N=r(N)+2
set obs `N'
replace bs=2 if relcol==.
replace relcol=-40 if relcol==. & _n==(`N'-1)
replace relcol=40 if relcol==. & _n==(`N')

reg relrpp relcol if bs==., r
predict prelrpp if bs==2
local b=string(_b[relcol], "%9.3f")
local s=string(_se[relcol], "%9.3f")
local r2=string(e(r2), "%9.3f")
local n=string(e(N), "%9.0fc")

sort relrpp
twoway (scatter relrpp relcol if bs==., msize(tiny) m(O) mcolor(gs12))  (scatter relrpp relcol if bs==1, msize(small) m(O) mcolor(black)) (line prelrpp relcol if bs==2, lcolor(gs1)) (line relcol relcol if bs==2, lcolor(gs7) lpattern(dash)), scheme(s1mono)  ytitle("Pairwise Difference of RPP") xtitle("Pairwise Difference of COLI") legend(label(1 "Raw data") label(2 "Binned Scatter") label(3 "OLS") label(4 "45{c 176} line") c(1) r(3) position(10) ring(0) region(lcolor(none) fcolor(none))) note("          {&beta} = `b' (`s')" "          R{superscript:2} = `r2'           " "          N=`n'              " " ", position(4) ring(0) size(medsmall))
graph export "results/AppendixFigureA1b.eps", replace
graph close

use "`aux'", clear

quantiles relcps, n(19) k(relcps) gen(group)
centile relcps, c(5(5)95)
forvalues k=1/19 {
	replace group=r(c_`k') if group==`k'
	}

tempfile aux0
save "`aux0'", replace

collapse (mean) relacs , by(group)

gen bs=1
rename group relcps

append using "`aux0'"

qui: cou
local N=r(N)+2
set obs `N'
replace bs=2 if relcps==.
replace relcps=-40 if relcps==. & _n==(`N'-1)
replace relcps=40 if relcps==. & _n==(`N')

reg relacs relcps if bs==., r
predict prelacs if bs==2
local b=string(_b[relcps], "%9.3f")
local s=string(_se[relcps], "%9.3f")
local r2=string(e(r2), "%9.3f")
local n=string(e(N), "%9.0fc")
		
sort relcps
twoway (scatter relacs relcps if bs==., msize(tiny) m(O) mcolor(gs12)) (scatter relacs relcps if bs==1, msize(small) m(O) mcolor(gs1)) (line prelacs relcps if bs==2, lcolor(gs1)) (line relcps relcps if bs==2, lcolor(gs7) lpattern(dash)), scheme(s1mono)  ytitle("Pairwise Difference of ACS") xtitle("Pairwise Difference of CPS") legend(label(1 "Raw data") label(2 "Binned Scatter") label(3 "OLS") label(4 "45{c 176} line") c(1) r(3) position(10) ring(0) region(lcolor(none) fcolor(none))) note("          {&beta} = `b' (`s')" "          R{superscript:2} = `r2'           " "          N=`n'              " " ", position(4) ring(0) size(medsmall))
graph export "results/AppendixFigureA1a.eps", replace
graph close
	
restore










* Figures A2 and A3: maps generated using QGIS










*** Appendix Figure A4: Distribution Over Time of Survey Responses and NRMP Rank Submissions
twoway (hist submitdate, w(1) bcolor(gs12) freq) (hist followup_end, w(1) bcolor(gs7) freq) (hist baseline_end, w(1) bcolor(gs3) freq), legend(label(1 "Submissions") label(2 "Follow-up") label(3 "Baseline")) scheme(s1mono) xline(20834, lpattern(dash)) xline(20872, lpattern(dash)) xtick(20825 20834 20851 20872 20890) xlabel(20825 "06 Jan 17" 20834 "15 Jan 17" 20851 "01 Feb 17" 20872 "22 Feb 17" 20890 "12 Mar 17") 
graph export "results/AppendixFigureA4.pdf", replace










*** Appendix Figure A5.a: Variation in Nominal Income, Earnings Rank and Cost of Living
preserve
gen medERdiff=lndiffwage
replace relinc_true=post_relinc

quantiles relinc_true, n(19) k(relinc_true) gen(group)
centile relinc_true, c(5(5)95)
forvalues k=1/19 {
	replace group=r(c_`k') if group==`k'
	}

tempfile aux0
save "`aux0'", replace

collapse (mean) medERdiff, by(group)

gen bs=1
rename group relinc_true

append using "`aux0'"

qui: cou
local N=r(N)+2
set obs `N'
qui: sum relinc_true
replace bs=2 if relinc_true==.
replace relinc_true=r(min) if relinc_true==. & _n==(`N'-1)
replace relinc_true=r(max) if relinc_true==. & _n==(`N')

reg medERdiff relinc_true if bs==.
predict prelinc_true if bs==2
local b=string(_b[relinc_true], "%9.3f")
local s=string(_se[relinc_true], "%9.3f")
local r2=string(e(r2), "%9.3f")
local n=string(e(N), "%9.0fc")

local depvar relinc_true
local var medERdiff

twoway (scatter `var' `depvar' if bs==., msize(tiny) mcolor(gs12) m(O)) (scatter `var' `depvar' if bs==1, msize(small) mcolor(gs1) m(O)) (line p`depvar' `depvar' if bs==2, lcolor(gs1)), scheme(s1mono)  ytitle("Pairwise Difference log(Residency Nominal Income)") xtitle("Pairwise Difference in Earnings Rank") legend(label(1 "Raw data") label(2 "Binned Scatter") label(3 "OLS") label(4 "45{c 176} line") c(2) r(3) position(10) ring(0) region(lcolor(none) fcolor(none))) note("          {&beta} = `b' (`s')" "          R{superscript:2} = `r2'           " "          N = `n'            " " ", position(4) ring(0) size(medsmall))
graph export "results/AppendixFigureA5a.eps", replace
graph close

restore

*** Appendix Figure A5.b: Variation in nominal wage and COL
preserve
gen relwage = lndiffwage
replace relpx_true=post_relpx

quantiles relpx_true, n(19) k(relpx_true) gen(group)
centile relpx_true, c(5(5)95)
forvalues k=1/19 {
	replace group=r(c_`k') if group==`k'
	}

tempfile aux0
save "`aux0'", replace

collapse (mean) relwage, by(group)

gen bs=1
rename group relpx_true

append using "`aux0'"

qui: cou
local N=r(N)+2
set obs `N'
qui: sum relpx_true
replace bs=2 if relpx_true==.
replace relpx_true=r(min) if relpx_true==. & _n==(`N'-1)
replace relpx_true=r(max) if relpx_true==. & _n==(`N')

reg relwage relpx_true if bs==.
predict prelpx_true if bs==2
local b=string(_b[relpx_true], "%9.3f")
local s=string(_se[relpx_true], "%9.3f")
local r2=string(e(r2), "%9.3f")
local n=string(e(N), "%9.0fc")

local depvar relpx_true
local var relwage

twoway (scatter `var' `depvar' if bs==., msize(tiny) mcolor(gs12) m(O)) (scatter `var' `depvar' if bs==1, msize(small) mcolor(gs1) m(O)) (line p`depvar' `depvar' if bs==2, lcolor(gs1)), scheme(s1mono)  ytitle("Pairwise Difference log(Residency Nominal Income)") xtitle("Pairwise Difference Cost of Living") legend(label(1 "Raw data") label(2 "Binned Scatter") label(3 "OLS") label(4 "45{c 176} line") c(2) r(3) position(10) ring(0) region(lcolor(none) fcolor(none))) note("          {&beta} = `b' (`s')" "          R{superscript:2} = `r2'            " "          N = `n'             " " ", position(4) ring(0) size(medsmall))
graph export "results/AppendixFigureA5b.eps", replace
graph close

restore











*** Appendix Table A6: Alternative Definition of Earnings Rank
use "Main Experiment/mainexperiment_confidential.dta", clear
	
keep id colhat* rpphat* incacs* inccps* metro* z_incacs* z_inccps* w_incacs*

reshape long colhat rpphat incacs inccps metro z_incacs z_inccps w_incacs, i(id) j(j)

gen cou=1
collapse (first) z_* colhat rpphat w_incacs (sum) cou, by(metro)

reg w_incacs z_incacs [w=cou], r
local b=string(_b[z_incacs], "%9.3f")
local s=string(_se[z_incacs], "%9.3f")
local r2=string(e(r2), "%9.3f")

twoway (scatter w_incacs z_incacs [w=cou], msize(vsmall) mcolor(black)) (lfit w_incacs z_incacs, lcolor(black)), scheme(s1mono) ytitle("Income ranking among all Working Age Population") xtitle("Income ranking among all Income Earners")  legend(label(1 "Weighted data") label(2 "OLS") c(1) r(3) position(11) ring(0) region(lcolor(none) fcolor(none))) note("          {&beta} = `b' (`s')" "          R{superscript:2} = `r2'           " " " " ", position(4) ring(0) size(medsmall))
graph export "results/AppendixFigureA6.eps", replace
graph close
	
clear











* Appendix Figure A7: Comparison Between Prior Beliefs and Statistics
use "Main Experiment/mainexperiment_confidential.dta", clear
foreach var in pre_relpx pre_relinc {
preserve

replace pre_relpx=pre_relpx*100
replace pre_relinc=pre_relinc*100

gen pre_truepx=rpphat1-rpphat2
gen pre_trueinc=incacs1-incacs2

if "`var'"=="pre_relpx" {
	local depvar "pre_truepx"
}
else {
	local depvar "pre_trueinc"
}

quantiles `depvar', n(19) k(`depvar') gen(group)
centile `depvar', c(5(5)95)
forvalues k=1/19 {
	replace group=r(c_`k') if group==`k'
	}

tempfile aux0
save "`aux0'", replace

collapse (mean) `var', by(group)

gen bs=1
rename group `depvar'

append using "`aux0'"

qui: cou
local N=r(N)+2
set obs `N'
qui: sum `depvar'
replace bs=2 if `depvar'==.
replace `depvar'=-80 if `depvar'==. & _n==(`N'-1)
replace `depvar'=80 if `depvar'==. & _n==(`N')

reg `var' `depvar' if bs==.
predict p`depvar' if bs==2
local b=string(_b[`depvar'], "%9.3f")
local s=string(_se[`depvar'], "%9.3f")
local r2=string(e(r2), "%9.3f")
local n=string(e(N), "%9.0fc")

if "`var'"=="pre_relpx" {
	twoway (scatter `var' `depvar' if bs==., msize(tiny) mcolor(gs12) m(O)) (scatter `var' `depvar' if bs==1, msize(small) mcolor(gs1) m(O)) (line p`depvar' `depvar' if bs==2, lcolor(gs1)) (line `depvar' `depvar' if bs==2, lcolor(gs7) lpattern(dash)), scheme(s1mono)  ytitle("Respondent's Prior Belief") xtitle("Estimate from the Regional Price Parity") xlabel(-80(20)80) ylabel(-80(20)80) xtick(-80(20)80) ytick(-80(20)80) legend(label(1 "Raw data") label(2 "Binned Scatter") label(3 "OLS") label(4 "45{c 176} line") c(2) r(3) position(10) ring(0) region(lcolor(none) fcolor(none))) note("          {&beta} = `b' (`s')" "          R{superscript:2} = `r2'           " "          N = `n'            " " ", position(4) ring(0) size(medsmall))
		graph export "results/`depvar'_`var'_binscatter.eps", replace
		graph close
	}
else  {
	twoway (scatter `var' `depvar' if bs==., msize(tiny) mcolor(gs12) m(O)) (scatter `var' `depvar' if bs==1, msize(small) mcolor(gs1) m(O)) (line p`depvar' `depvar' if bs==2, lcolor(gs1))  (line `depvar' `depvar' if bs==2, lcolor(gs7) lpattern(dash)), scheme(s1mono)  ytitle("Respondent's Prior Belief") xtitle("Estimate from the American Community Survey") xlabel(-80(20)80) ylabel(-80(20)80) xtick(-80(20)80) ytick(-80(20)80) legend(label(1 "Raw data") label(2 "Binned Scatter") label(3 "OLS")  label(4 "45{c 176} line") c(1) r(4) position(10) ring(0) region(lcolor(none) fcolor(none))) note("          {&beta} = `b' (`s')" "          R{superscript:2} = `r2'           " "          N = `n'            " " ", position(4) ring(0) size(medsmall))
		graph export "results/`depvar'_`var'_binscatter.eps", replace
		graph close
	}

restore
}

!mv results/pre_trueinc_pre_relinc_binscatter.eps  results/AppendixFigureA7a.eps
!mv results/pre_truepx_pre_relpx_binscatter.eps  results/AppendixFigureA7b.eps










*** Appendix Figure A8: Reduced-Form Evidence of Learning in the Information-Provision Experiment by Feed- back Source
use "Main Experiment/mainexperiment_confidential.dta", clear
foreach var in px_pregap inc_pregap { 

if "`var'"=="px_pregap" {
	local depvar "px_diff"
	local sourcevar "sourcecol"
	local sourceval "colhat rpphat"
}
else {
	local depvar "inc_diff"
	local sourcevar "sourceinc"
	local sourceval "acs cps"
 }

foreach sv in `sourceval' {
preserve

keep if `sourcevar'=="`sv'"

forvalues i=1/2 {
gen px_shown`i' = colhat`i' if sourcecol=="colhat"
replace px_shown`i' = rpphat`i' if sourcecol=="rpphat"
gen px_diff`i'=post_px`i'-pre_px`i'
gen lr_px_diff`i'=lr_px`i'-pre_px`i'
gen px_pregap`i'=px_shown`i'-pre_px`i'
gen px_shown_fake`i' = rpphat`i' if sourcecol=="colhat"
replace px_shown_fake`i' = colhat`i' if sourcecol=="rpphat" 
gen px_pregap_fake`i'=px_shown_fake`i'-pre_px`i'

gen inc_shown`i' = incacs`i' if sourceinc=="acs"
replace inc_shown`i' = inccps`i' if sourceinc=="cps"
gen inc_diff`i'=post_inc`i'-pre_inc`i'
gen lr_inc_diff`i'=lr_inc`i'-pre_inc`i'
gen inc_pregap`i'=inc_shown`i'-pre_inc`i'
gen inc_shown_fake`i' = incacs`i' if sourcecol=="colhat"
replace inc_shown_fake`i' = inccps`i' if sourcecol=="rpphat"
gen inc_pregap_fake`i'=inc_shown_fake`i'-pre_inc`i'

}

keep id px_diff* px_pregap* px_pregap_fake* inc_diff* inc_pregap* inc_pregap_fake* lr_px_diff* lr_inc_diff* sourcecol sourceinc

reshape long px_diff px_pregap px_pregap_fake inc_diff inc_pregap inc_pregap_fake lr_px_diff lr_inc_diff, i(id) j(j)

quantiles `var', n(19) k(`var') gen(group)
centile `var', c(5(5)95)
forvalues k=1/19 {
	replace group=r(c_`k') if group==`k'
	}

tempfile aux0
save "`aux0'", replace

collapse (mean) `depvar', by(group)

gen bs=1
rename group `var'

append using "`aux0'"

qui: cou
local N=r(N)+2
set obs `N'
qui: sum `var'
replace bs=2 if `var'==.
replace `var'=r(min) if `var'==. & _n==(`N'-1)
replace `var'=r(max) if `var'==. & _n==(`N')

reg `depvar' `var' if bs==.
predict p`depvar' if bs==2
local b=string(_b[`var'], "%9.3f")
local s=string(_se[`var'], "%9.3f")
local r2=string(e(r2), "%9.3f")
local n=string(e(N), "%9.0fc")
reg lr_`depvar' `var' if bs==.
predict plr_`depvar' if bs==2
local lr_b=string(_b[`var'], "%9.3f")
local lr_s=string(_se[`var'], "%9.3f")
local lr_r2=string(e(r2), "%9.3f")
local lr_n=string(e(N), "%9.0fc")

if "`var'"=="px_pregap" {
	twoway (scatter `depvar' `var' if bs==., msize(tiny) mcolor(gs12) m(O)) (scatter `depvar' `var' if bs==1, msize(small) mcolor(gs1) m(O)) (line p`depvar' `var' if bs==2, lcolor(gs1)) , scheme(s1mono) xline(0, lpattern(dot) lcolor(gs5)) yline(0, lpattern(dot) lcolor(gs5)) xtick(-60(20)80) xlabel(-60(20)80) ytick(-80(20)80) ylabel(-80(20)80) ytitle("Posterior Belief - Prior Belief") xtitle("Feedback Provided - Prior Belief") legend(label(1 "Raw data") label(2 "Binned Scatter") label(3 "OLS") c(1) r(3) position(11) ring(0) region(lcolor(none) fcolor(none))) note("          {&alpha} = `b' (`s')" "          N=`n'              " " ", position(5) ring(0) size(medsmall))
		graph export "results/`depvar'_`var'_`sv'_binscatter.eps", replace
		graph close
	}
else  {
	twoway (scatter `depvar' `var' if bs==., msize(tiny) mcolor(gs12) m(O)) (scatter `depvar' `var' if bs==1, msize(small) mcolor(gs1) m(O)) (line p`depvar' `var' if bs==2, lcolor(gs1)) , scheme(s1mono) xline(0, lpattern(dot) lcolor(gs5)) yline(0, lpattern(dot) lcolor(gs5)) xtick(-60(20)80) xlabel(-60(20)80) ytick(-80(20)80) ylabel(-80(20)80) ytitle("Posterior Belief - Prior Belief") xtitle("Feedback Provided - Prior Belief") legend(label(1 "Raw data") label(2 "Binned Scatter") label(3 "OLS") c(1) r(3) position(11) ring(0) region(lcolor(none) fcolor(none))) note("          {&alpha} = `b' (`s')" "          N=`n'              " " ", position(5) ring(0) size(medsmall))
		graph export "results/`depvar'_`var'_`sv'_binscatter.eps", replace
		graph close
	}
	
restore

}
}

!mv results/inc_diff_inc_pregap_cps_binscatter.eps  results/AppendixFigureA8a.eps
!mv results/inc_diff_inc_pregap_acs_binscatter.eps  results/AppendixFigureA8b.eps
!mv results/px_diff_px_pregap_rpphat_binscatter.eps  results/AppendixFigureA8c.eps
!mv results/px_diff_px_pregap_colhat_binscatter.eps  results/AppendixFigureA8d.eps










*** Figure A9: Correlation between Earnings Rank, Cost of Living and Program Quality
use "Main Experiment/mainexperiment_confidential.dta", clear

gen relrpp = rpphat1 - rpphat2
gen relcol = colhat1 - colhat2
gen relacs = incacs1 - incacs2
gen relcps = inccps1 - inccps2

correl relacs relrpp rel_res

gen similar=abs(rel_res)<.1

replace rel_res=rel_res*100

tempfile aux
save "`aux'", replace

quantiles rel_res, n(19) k(rel_res) gen(group)
centile rel_res, c(5(5)95)
forvalues k=1/19 {
	replace group=r(c_`k') if group==`k'
	}

tempfile aux0
save "`aux0'", replace

collapse (mean) relrpp , by(group)

gen bs=1
rename group rel_res

append using "`aux0'"

qui: cou
local N=r(N)+2
set obs `N'
replace bs=2 if rel_res==.
replace rel_res=-90 if rel_res==. & _n==(`N'-1)
replace rel_res=90 if rel_res==. & _n==(`N')

reg relrpp rel_res if bs==., r
predict prelrpp if bs==2
local b=string(_b[rel_res], "%9.3f")
local s=string(_se[rel_res], "%9.3f")
local r2=string(e(r2), "%9.3f")
local n=string(e(N), "%9.0fc")

sort relrpp
twoway (scatter relrpp rel_res if bs==., msize(tiny) m(O) mcolor(gs12))  (scatter relrpp rel_res if bs==1, msize(small) m(O) mcolor(black)) (line prelrpp rel_res if bs==2, lcolor(gs1)) (line relcol rel_res if bs==2, lcolor(gs7) lpattern(dash)), scheme(s1mono)  ytitle("Pairwise Difference of Cost of Living") xtitle("Pairwise Difference of Residency Program Quality") legend(label(1 "Raw data") label(2 "Binned Scatter") label(3 "OLS") label(4 "45{c 176} line") c(1) r(3) position(10) ring(0) region(lcolor(none) fcolor(none))) note("          {&beta} = `b' (`s')" "          R{superscript:2} = `r2'           " "          N=`n'              " " ", position(4) ring(0) size(medsmall))
graph export "results/AppendixFigureA9b.eps", replace
graph close

use "`aux'", clear

quantiles rel_res, n(19) k(rel_res) gen(group)
centile rel_res, c(5(5)95)
forvalues k=1/19 {
	replace group=r(c_`k') if group==`k'
	}

tempfile aux0
save "`aux0'", replace

collapse (mean) relacs , by(group)

gen bs=1
rename group rel_res

append using "`aux0'"

qui: cou
local N=r(N)+2
set obs `N'
replace bs=2 if rel_res==.
replace rel_res=-90 if rel_res==. & _n==(`N'-1)
replace rel_res=90 if rel_res==. & _n==(`N')

reg relacs rel_res if bs==., r
predict prelacs if bs==2
local b=string(_b[rel_res], "%9.3f")
local s=string(_se[rel_res], "%9.3f")
local r2=string(e(r2), "%9.3f")
local n=string(e(N), "%9.0fc")
		
sort relcps
twoway (scatter relacs rel_res if bs==., msize(tiny) m(O) mcolor(gs12)) (scatter relacs rel_res if bs==1, msize(small) m(O) mcolor(gs1)) (line prelacs rel_res if bs==2, lcolor(gs1)) (line relcps rel_res if bs==2, lcolor(gs7) lpattern(dash)), scheme(s1mono)  ytitle("Pairwise Difference of Earnings Rank") xtitle("Pairwise Difference of Residency Program Quality") legend(label(1 "Raw data") label(2 "Binned Scatter") label(3 "OLS") label(4 "45{c 176} line") c(1) r(3) position(10) ring(0) region(lcolor(none) fcolor(none))) note("          {&beta} = `b' (`s')" "          R{superscript:2} = `r2'           " "          N=`n'              " " ", position(4) ring(0) size(medsmall))
graph export "results/AppendixFigureA9a.eps", replace
graph close
	

	








*** Appendix Figure A10: Correlation between (Posterior) Beliefs in Baseline and Follow-Up Surveys
use "Main Experiment/mainexperiment_confidential.dta", clear

foreach var in px inc {

preserve
drop if lr_inc1==.

keep id post_inc1 post_inc2 lr_inc1 lr_inc2 post_px1 post_px2 lr_px1 lr_px2

reshape long post_inc post_px lr_inc lr_px, i(id) j(j)

quantiles post_`var', n(19) k(post_`var') gen(group)
centile post_`var', c(5(5)95)
forvalues k=1/19 {
	replace group=r(c_`k') if group==`k'
	}

tempfile aux0
save "`aux0'", replace

collapse (mean) lr_`var', by(group)

gen bs=1
rename group post_`var'

append using "`aux0'"

qui: cou
local N=r(N)+2
set obs `N'
qui: sum post_`var'
replace bs=2 if post_`var'==.
replace post_`var'=r(min) if post_`var'==. & _n==(`N'-1)
replace post_`var'=r(max) if post_`var'==. & _n==(`N')

reg lr_`var' post_`var' if bs==.
predict p`var' if bs==2
local b=string(_b[post_`var'], "%9.3f")
local s=string(_se[post_`var'], "%9.3f")
local r2=string(e(r2), "%9.3f")
local n=string(e(N), "%9.0fc")

if "`var'"=="px" {
twoway (scatter lr_`var' post_`var' if bs==., msize(tiny) mcolor(gs12) m(O)) (scatter lr_`var' post_`var' if bs==1, msize(small) mcolor(gs1) m(O)) (line p`var' post_`var' if bs==2, lcolor(gs1)) , scheme(s1mono) xline(100, lpattern(dot) lcolor(gs5)) yline(100, lpattern(dot) lcolor(gs5))  ytitle("Posterior in Follow-up") xtitle("Posterior in Baseline") legend(label(1 "Raw data") label(2 "Binned Scatter") label(3 "OLS") c(1) r(3) position(11) ring(0) region(lcolor(none) fcolor(none))) note("          {&beta} = `b' (`s')" "          N=`n'              " " ", position(5) ring(0) size(medsmall))
		graph export "results/lr_`var'_post_`var'_binscatter.eps", replace
		graph close
}
else {
twoway (scatter lr_`var' post_`var' if bs==., msize(tiny) mcolor(gs12) m(O)) (scatter lr_`var' post_`var' if bs==1, msize(small) mcolor(gs1) m(O)) (line p`var' post_`var' if bs==2, lcolor(gs1)) , scheme(s1mono)  ytitle("Posterior in Follow-up") xtitle("Posterior in Baseline") legend(label(1 "Raw data") label(2 "Binned Scatter") label(3 "OLS") c(1) r(3) position(11) ring(0) region(lcolor(none) fcolor(none))) note("          {&beta} = `b' (`s')" "          N=`n'              " " ", position(5) ring(0) size(medsmall))
		graph export "results/lr_`var'_post_`var'_binscatter.eps", replace
		graph close
}

restore
}

!mv results/lr_inc_post_inc_binscatter.eps results/AppendixFigureA10a.eps
!mv results/lr_px_post_px_binscatter.eps results/AppendixFigureA10b.eps










*** Appendix Figure A11: Survey Responses, Preferences over Hypothetical Changes to Earnings Rank and Cost of Living
hist eventa, scheme(s1mono) percent xlabel(1 "Worse-off" 2 "Slightly Worse" 3 "The Same" 4 "Slightly Better" 5 "Better-off", angle(45)) xtitle("") discrete
graph export "results/AppendixFigureA11b.eps", replace
graph close

hist eventb, scheme(s1mono) percent xlabel(1 "Worse-off" 2 "Slightly Worse" 3 "The Same" 4 "Slightly Better" 5 "Better-off", angle(45)) xtitle("") discrete
graph export "results/AppendixFigureA11a.eps", replace
graph close










*** Appendix Figure A12: Effect of Earning Rank Feedback on Posterior Belief on Cost of Living (and vice-versa)
* COL info on ER 
use "Main Experiment/mainexperiment_confidential.dta", clear

preserve

forvalues i=1/2 {
gen px_shown`i' = colhat`i' if sourcecol=="colhat"
replace px_shown`i' = rpphat`i' if sourcecol=="rpphat"
gen px_diff`i'=post_px`i'-pre_px`i'
gen lr_px_diff`i'=lr_px`i'-pre_px`i'
gen px_pregap`i'=px_shown`i'-pre_px`i'
gen px_shown_fake`i' = rpphat`i' if sourcecol=="colhat"
replace px_shown_fake`i' = colhat`i' if sourcecol=="rpphat"
gen px_pregap_fake`i'=px_shown_fake`i'-pre_px`i'

gen inc_shown`i' = incacs`i' if sourceinc=="acs"
replace inc_shown`i' = inccps`i' if sourceinc=="cps"
gen inc_diff`i'=post_inc`i'-pre_inc`i'
gen lr_inc_diff`i'=lr_inc`i'-pre_inc`i'
gen inc_pregap`i'=inc_shown`i'-pre_inc`i'
gen inc_shown_fake`i' = incacs`i' if sourcecol=="colhat"
replace inc_shown_fake`i' = inccps`i' if sourcecol=="rpphat"
gen inc_pregap_fake`i'=inc_shown_fake`i'-pre_inc`i'

}

keep id px_diff* px_pregap* px_pregap_fake* inc_diff* inc_pregap* inc_pregap_fake* lr_px_diff* lr_inc_diff* sourcecol sourceinc

reshape long px_diff px_pregap px_pregap_fake inc_diff inc_pregap inc_pregap_fake lr_px_diff lr_inc_diff, i(id) j(j)

reg inc_diff inc_pregap
predict yhat, resid
reg px_pregap inc_pregap
predict xhat, resid

reg yhat xhat, r
local b=string(_b[xhat], "%9.3f")
local s=string(_se[xhat], "%9.3f")
local r2=string(e(r2), "%9.3f")
local n=string(e(N),"%9.0fc")

quantiles xhat, n(19) k(xhat) gen(group)
centile xhat, c(5(5)95)
forvalues k=1/19 {
	replace group=r(c_`k') if group==`k'
	}

egen bs_yhat=mean(yhat), by(group)
bys group: replace bs_yhat=. if _n>1

twoway (scatter yhat xhat, msize(tiny) mcolor(gs12) m(O)) (scatter bs_yhat group, msize(small) mcolor(gs1) m(O)) (lfit yhat xhat, lcolor(gs1)), scheme(s1mono) xline(0, lpattern(dot) lcolor(gs5)) yline(0, lpattern(dot) lcolor(gs5))  ytitle("Adjusted (Posterior Belief - Prior Belief)") xtitle("Adjusted (Feedback Provided - Prior Belief)") legend(label(1 "Raw data") label(2 "Binned Scatter") label(3 "OLS") c(1) r(3) position(11) ring(0) region(lcolor(none) fcolor(none))) note("          {&alpha} = `b' (`s')" "          N=`n'              " " ", position(5) ring(0) size(medsmall))
graph export "results/AppendixFigureA12c.eps", replace
graph close

drop yhat xhat group bs_yhat

* ER info on COL
reg px_diff px_pregap
predict yhat, resid
reg inc_pregap px_pregap
predict xhat, resid

reg yhat xhat, r
local b=string(_b[xhat], "%9.3f")
local s=string(_se[xhat], "%9.3f")
local r2=string(e(r2), "%9.3f")
local n=string(e(N),"%9.0fc")

quantiles xhat, n(19) k(xhat) gen(group)
centile xhat, c(5(5)95)
forvalues k=1/19 {
	replace group=r(c_`k') if group==`k'
	}

egen bs_yhat=mean(yhat), by(group)
bys group: replace bs_yhat=. if _n>1


twoway (scatter yhat xhat, msize(tiny) mcolor(gs12) m(O)) (scatter bs_yhat group, msize(small) mcolor(gs1) m(O)) (lfit yhat xhat, lcolor(gs1)), scheme(s1mono) xline(0, lpattern(dot) lcolor(gs5)) yline(0, lpattern(dot) lcolor(gs5))  ytitle("Adjusted (Posterior Belief - Prior Belief)") xtitle("Adjusted (Feedback Provided - Prior Belief)") legend(label(1 "Raw data") label(2 "Binned Scatter") label(3 "OLS") c(1) r(3) position(11) ring(0) region(lcolor(none) fcolor(none))) note("          {&alpha} = `b' (`s')" "          N=`n'               " " ", position(5) ring(0) size(medsmall))
graph export "results/AppendixFigureA12a.eps", replace
graph close

drop yhat xhat group bs_yhat

*** LR Cross-learning
* COL info on ER 
reg lr_inc_diff inc_pregap
predict yhat, resid
reg px_pregap inc_pregap
predict xhat, resid

reg yhat xhat, r
local b=string(_b[xhat], "%9.3f")
local s=string(_se[xhat], "%9.3f")
local r2=string(e(r2), "%9.3f")
local n=string(e(N),"%9.0fc")

quantiles xhat, n(19) k(xhat) gen(group)
centile xhat, c(5(5)95)
forvalues k=1/19 {
	replace group=r(c_`k') if group==`k'
	}

egen bs_yhat=mean(yhat), by(group)
bys group: replace bs_yhat=. if _n>1


twoway (scatter yhat xhat, msize(tiny) mcolor(gs12) m(O)) (scatter bs_yhat group, msize(small) mcolor(gs1) m(O)) (lfit yhat xhat, lcolor(gs1)), scheme(s1mono) xline(0, lpattern(dot) lcolor(gs5)) yline(0, lpattern(dot) lcolor(gs5))  ytitle("Adjusted (Posterior Belief - Prior Belief)") xtitle("Adjusted (Feedback Provided - Prior Belief)") legend(label(1 "Raw data") label(2 "Binned Scatter") label(3 "OLS") c(1) r(3) position(11) ring(0) region(lcolor(none) fcolor(none))) note("          {&alpha} = `b' (`s')" "          N=`n'               " " ", position(5) ring(0) size(medsmall))
graph export "results/AppendixFigureA12d.eps", replace
graph close

drop yhat xhat group bs_yhat

* ER info on COL
reg lr_px_diff px_pregap
predict yhat, resid
reg inc_pregap px_pregap
predict xhat, resid

reg yhat xhat, r
local b=string(_b[xhat], "%9.3f")
local s=string(_se[xhat], "%9.3f")
local r2=string(e(r2), "%9.3f")
local n=string(e(N),"%9.0fc")

quantiles xhat, n(19) k(xhat) gen(group)
centile xhat, c(5(5)95)
forvalues k=1/19 {
	replace group=r(c_`k') if group==`k'
	}

egen bs_yhat=mean(yhat), by(group)
bys group: replace bs_yhat=. if _n>1

twoway (scatter yhat xhat, msize(tiny) mcolor(gs12) m(O)) (scatter bs_yhat group, msize(small) mcolor(gs1) m(O)) (lfit yhat xhat, lcolor(gs1)), scheme(s1mono) xline(0, lpattern(dot) lcolor(gs5)) yline(0, lpattern(dot) lcolor(gs5))  ytitle("Adjusted (Posterior Belief - Prior Belief)") xtitle("Adjusted (Feedback Provided - Prior Belief)") legend(label(1 "Raw data") label(2 "Binned Scatter") label(3 "OLS") c(1) r(3) position(11) ring(0) region(lcolor(none) fcolor(none))) note("          {&alpha} = `b' (`s')" "          N=`n'               " " ", position(5) ring(0) size(medsmall))
graph export "results/AppendixFigureA12b.eps", replace
graph close

drop yhat xhat group bs_yhat

restore
